import logging


class Logger:

    def log(self, message):
        pass


class FileLogger(Logger):

    def log(self, message):
        # 实现将日志写入文件的逻辑

        pass


class DatabaseLogger(Logger):

    def log(self, message):
        # 实现将日志写入数据库的逻辑

        pass


class LoggerFactory:

    @staticmethod
    def create_logger(logger_type):

        if logger_type == "file":

            return FileLogger()

        elif logger_type == "database":

            return DatabaseLogger()

        else:

            raise ValueError("Invalid logger type")


# 使用工厂方法创建不同类型的日志记录器对象

logger_factory = LoggerFactory()

logger = logger_factory.create_logger("file")

logger.log("Log message")
